package com.iss.okair.controller.assetstrans;


import com.iss.common.Message;
import com.iss.common.UuidTools;
import com.iss.okair.db.entity.Assetstrans;

import com.iss.okair.service.assets.AssetstransService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/logic/trans/car")
public class AssetstransCarController {
    @Autowired
    private AssetstransService service;
    @RequestMapping("/instock")
    public Message add(Assetstrans tran){
        Message msg = new Message();
        if(service.add(tran)){
            //成功
            msg.setError(false);
            msg.setMsg("保存成功");
        }else{
            msg.setError(true);
            msg.setMsg("保存失败");
        }

        return msg;
    }
    @RequestMapping("/{transtype}")
    public Message Use(@PathVariable("transtype") String transtype, Assetstrans finance){
        Message msg =new Message();
        finance.setId(UuidTools.buildUUID());
        if (service.Use(transtype,finance)){
            msg.setError(false);
            msg.setMsg("成功");
        }else {
            msg.setError(true);
            msg.setMsg("失败");
        }
        return  msg;
    }
}
